1. Field of the Invention
The present invention relates to a TRIM control mechanism of a file system established on a solid state drive (SSD), and more particularly, to a method, an apparatus and a computer program product arranged for adaptively managing an SSD.
2. Description of the Prior Art
According to related arts, after a traditional solid state drive (SSD) has been used for a period of time, the access efficiency thereof will greatly drop due to the inherent characteristics of the SSD. To recover the desired access performance of the SSD, a garbage collection mechanism is usually utilized to recycle and re-use storage spaces. However, when files are deleted, only the metadata located in the upper layer, such as the file system layer, will be changed. In this situation, the lower layer of the SSD will not be informed. Hence, the storage space corresponding to the deleted data will not actually be recycled, this results in degraded access performance of the SSD.
In related arts, the TRIM command is used to solve the aforementioned issue. The TRIM command is a standard hard drive command. Through utilizing the TRIM command, when the file system deletes files, the SSD may be informed of which space is no longer used. Recently, due to the development of SSDs, most of current operating systems support the TRIM command. Two traditional schemes for issuing the TRIM command are introduced as follows.
Please refer to FIG. 1, which is a diagram illustrating a related art online issue scheme. The online issue scheme may be realized as: immediately sending a TRIM command sent to the SSD upon deletion of a file. For example, when a file with a size of 500K is deleted and a corresponding TRIM command is issued (denoted as “delete 500K” and “TRIM 500K,” respectively, in FIG. 1, wherein K represents Kilobyte), then a file with a size of 5K is deleted and a corresponding TRIM command is issued (denoted as “delete 5K” and “TRIM 5K,” respectively, in FIG. 1), then a file with a size of 1K is deleted and a corresponding TRIM command is issued (denoted as “delete 1K” and “TRIM 1K,” respectively, in FIG. 1), then a file with a size of 5K is deleted and a corresponding TRIM command is issued (denoted as “delete 5K” and “TRIM 5K,” respectively, in FIG. 1), and then a file with a size of 3K is deleted and a corresponding TRIM command is issued (denoted as “delete 3K” and “TRIM 3K,” respectively, in FIG. 1). However, some side effects are introduced due to the online issue scheme. For example, the online issue scheme increases the system loading and affects the reading and writing performances. This is because sending the TRIM command will occupy the bandwidth of the SSD. Further, after the SSD receives the TRIM command, the garbage collection mechanism may be enabled. Hence, the online issue scheme will temporarily make the SSD have reading and writing performance drop.
Please refer to FIG. 2, which is a diagram illustrating a related art offline issue scheme. The offline issue scheme may be realized as: instead of immediately sending the TRIM command to the SSD upon deletion of a file, sending the TRIM command to the SSD afterwards. Specifically, according to the offline issue scheme, the TRIM commands are all issued at a predetermined time. For example, a file with a size of 500K is deleted (denoted as “delete 500K” in FIG. 2), then a file with a size of 5K is deleted (denoted as “delete 5K” in FIG. 2), then a file with a size of 1K is deleted (denoted as “delete 1K” in FIG. 2), then a file with a size of 5K is deleted (denoted as “delete 5K” in FIG. 2), and then a file with a size of 3K is deleted (denoted as “delete 3K” in FIG. 2). The conventional execution condition 10 is the current time equal to the aforementioned predetermined time, such as a scheduling time or a user-defined time, which is denoted as “scheduling time or user-defined time” in FIG. 2. However, the offline issue scheme will generate some problems such as some side effects. For example, the software module “fstrim” in the “Ubuntu” operating system may scan the whole file system when executed for the first time after the computer is powered on, in order to find all storage spaces with no valid data stored therein, and then issue the TRIM commands to all the found storage spaces with no valid data stored therein. However, the timing of performing the software module “fstrim” needs to be carefully considered. If it is performed based on a scheduling manner, the scan operation is not effective and increases the system loading when the data deletion amount is not large or even zero. If it is manually triggered by the user, the user may feel inconvenient. For another example, the “Android” operating system may try to issue the TRIM commands only when the device is charged through some mechanisms. More particularly, the frequency of issuing the TRIM command may be about once a day. However, the increased system loading resulting from performing the scan operation under the situation that the data deletion amount is not larger still exists.
In view of above, the traditional schemes cannot improve the access performance of the SSD without introducing side effects. Therefore, a novel method for improving the access performance of the SSD is needed.